import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {
  // ElementPlusResolver,
  VantResolver
} from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    // AutoImport({
    //   resolvers: [ElementPlusResolver()]
    // }),
    Components({
      resolvers: [VantResolver()]
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    port: 5173,
    host: '0.0.0.0',
    proxy: {
      // home中的search
      '/homesearch': {
        target: 'https://i.meituan.com',
        pathRewrite: {
          '^/homesearch': ''
        }
      },
      '/ajax': {
        target: 'https://m.maoyan.com',
        pathRewrite: { '^/ajax': ' ' }
      }
      // '/openapi': {
      //   //解决vite的https请求问题。
      //   secure: false,
      //   target: 'https://i.waimai.meituan.com'
      // }
    }
  }
})
